package org;

import net.bytebuddy.asm.Advice;

import java.lang.reflect.Method;

public class LoggerAdvisor {
    @Advice.OnMethodEnter
    public static long onMethodEnter(@Advice.Origin Method method, @Advice.AllArguments Object[] arguments) {
        long l = System.currentTimeMillis();
        System.out.println("args " + arguments);
        return l;
    }

    @Advice.OnMethodExit
    //(onThrowable = Throwable.class)
    public static void onMethodExit(
            @Advice.Origin Method method
//           , @Advice.This Object thisObject
            , @Advice.AllArguments Object[] arguments
//            ,@Advice.Return Object ret
//            ,@Advice.Thrown Throwable throwable
//            ,@Advice.Enter long startTime
    ) {
        System.out.println("ret:"
//                        +ret
//              + " , startTime: " +startTime
//                +" , this: "+thisObject
                        + " , args: " + arguments
//                +", throwable: "+throwable
        );
    }
}
